<!-- 确认订单 -->
<template>
  <view>
    <!-- 地址栏 -->
    <view
      class="head_box"
      v-if="addressData"
      @tap="jump('/pages/user/address/list', { from: 'order' })">
      <view class="add-address-box u-flex u-flex-1" v-if="!addressId">
        <view class="box-bg u-p-30 u-flex-1 u-flex u-row-between">
          <text class="select-notice">请选择收货地址</text>
          <text
            class="u-iconfont uicon-arrow-right"
            style="color: #bfbfbf"
          ></text>
        </view>
      </view>
      <view class="add-address-box u-p-30" v-else>
        <view class="top u-flex">
          <text class="name">{{ addressData.consignee }}</text>
          <text class="phone">{{ addressData.phone }}</text>
          <text class="tag" :style="{'background':$CHANGEB,'color':$COLOR}" v-show="addressData.isDefault == 1">默认</text>
        </view>
        <view class="detail u-flex u-row-between">
          <view class="address">
            {{ addressData.province }}{{ addressData.city
            }}{{ addressData.area }}{{ addressData.address }}
          </view>
          <text
            class="u-iconfont uicon-arrow-right"
            style="color: #bfbfbf"
          ></text>
        </view>
      </view>
    </view>
	<!-- 商品详情 -->
	  <view class="centent-box detail">
		  <view class="detail_goods">
			<view class="detail-img">
				<image mode="aspectFit" style="width:100%;height:100%;" :src="goodsInfo.slideshows ? goodsInfo.slideshows : goodsInfo.slideshows"/>
			</view>
			<view class="detail-info">
				<view class="detail-info-title">
					<text>{{goodsInfo.msg}}</text>
				</view>
				<view class="detail-info-line">
					<text class="detail-info-text">套餐：{{goodsInfo.detail}}</text>
				</view>
				<view class="detail-info-trem detail-info-line">
					<text class="detail-info-text " style="width:50%;">数量：{{goodsInfo.saleQuantity}}</text>
					<!-- <text class="detail-info-text" style="width:50%;">租期：{{goodsInfo.trem == '1期' ? '15天':goodsInfo.trem}}</text> -->
				</view>
			</view>
		  </view>


		 <view class="detail_time" :style="{backgroundColor: $CHANGEB}">
			<view class="detail_time_min">
			  <view class="detail_time_min_L">
				<image mode="scaleToFill" style="width:100%; height:100%;" :src="$IMAGE_URL + '/confirm_start.png'"/>
			  </view>
			  <view class="detail_time_min_R">
				<view class="detail_time_min_R_tit">预计起租日</view>
				<view class="detail_time_min_R_text">{{ startTimer }}</view>
			  </view>
			</view>
			<view class="detail_time_min detail_time_minT">
			  <view class="detail_time_min_L">
				<image mode="scaleToFill" style="width:100%; height:100%;" :src="$IMAGE_URL + '/confirm_start.png'"/>
			  </view>
			  <view class="detail_time_min_R">
				<view class="detail_time_min_R_tit">归还日</view>
				<view class="detail_time_min_R_text">{{ endTimer }}</view>
			  </view>
			</view>
		  </view>

		  <view class="detail_hint">
			<image class="detail_hint_img" mode="scaleToFill" :src="$IMAGE_URL + '/confirm_hint.png'" />
			<text class="detail_hint_text">提示：快递运输期间不算租期，实际起租日为快递签收当天</text>
		  </view>

		</view>
		
		  <!-- rent -->
		  <view style="padding-bottom: 210rpx;">
		  	
		        <view class="centent-box rent">
		           <view class="rent-box rent-frist">
		                <text class="rent-frist-tit">商品总价</text>
		                <!-- <text class="rent-frist-tit" v-else>首月租金付款</text> -->
		                <!-- <text class="rent-frist-num" v-if="goodsInfo.promotionType == 1">￥1.00</text> -->
		                <text class="rent-frist-num" >￥{{((goodsInfo.price)/100).toFixed(2)}}</text>
		            </view>
		            <view class="rent-box">
		                <text>总周期:</text>
		                <text>{{goodsInfo.cycle}}</text>
		            </view>
					<view class="rent-box">
					    <text>周期金额:</text>
					    <text>{{goodsInfo.dayRent}}</text>
					</view>
					<view class="rent-box">
					    <text>发货:</text>
					    <text>48小时内发货</text>
					</view>
					<view class="rent-box" v-if="goodsInfo.smash">
					    <text>碎屏保障:</text>
					    <text>{{((goodsInfo.smash)/100).toFixed(2)}}</text>
					</view>
					
		        </view>
		
		        <view class="centent-box identity" style="background: linear-gradient(90deg, #FFEACF 0%, #FFFCF7 100%);" v-if="!idSta">
		          <view class="identity_L">
		            <view class="identity_L_tit">上传身份证照片</view>
		            <view class="identity_L_text">完善实名信息，加快审核速度</view>
		          </view>
		          <view class="identity_R">
		            <view class="identity_R_btn" @tap="onUploadIdCard">去上传</view>
		          </view>
		          <!-- <image class="identity_bc" mode="scaleToFill" :src="$IMAGE_URL + '/groupon_x_bg.png'" /> -->
		        </view>
				
				 <!-- remark -->
				<view class="centent-box remark">
					<text class="text-email-title">下单备注：</text>
					<input type="text" :value="goodsInfo.cont" onInput="onNote" style="flex:1;" placeholder="请在这留下您的备注" />
				</view>
				<view class="centent-box remark">
					<text class="text-email-title">电子邮箱：</text>
					<input type="text" v-model="goodsInfo.strEmail" onInput="getEmail" style="flex:1;" placeholder="请输入电子邮箱" />
				</view>
				
				<view class="centent-box rent">
				  <view class="rent-box rent-frist">
				       <text class="rent-frist-tit">紧急联系人1</text>
				   </view>
				    <view class="rent-box">
				        <text class="text-email-title">姓名:</text>
				        <input type="text" v-model="goodsInfo.name1" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入姓名" />
				    </view>
					<view class="rent-box">
					    <text>电话:</text>
					    <input type="text" v-model="goodsInfo.phone1" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入电话" />
					</view>
					<view class="rent-box">
					    <text>关系:</text>
					    <input type="text" v-model="goodsInfo.relationship1" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入关系" />
					</view>
				</view>
				
				<view class="centent-box rent">
				  <view class="rent-box rent-frist">
				       <text class="rent-frist-tit">紧急联系人2</text>
				   </view>
				    <view class="rent-box">
				        <text class="text-email-title">姓名:</text>
				        <input type="text" v-model="goodsInfo.name2" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入姓名" />
				    </view>
					<view class="rent-box">
					    <text>电话:</text>
					    <input type="text" v-model="goodsInfo.phone2" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入电话" />
					</view>
					<view class="rent-box">
					    <text>关系:</text>
					    <input type="text" v-model="goodsInfo.relationship2" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入关系" />
					</view>
				</view>
				
				<view class="centent-box rent">
				  <view class="rent-box rent-frist">
				       <text class="rent-frist-tit">紧急联系人3</text>
				   </view>
				    <view class="rent-box">
				        <text class="text-email-title">姓名:</text>
				        <input type="text" v-model="goodsInfo.name3" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入姓名" />
				    </view>
					<view class="rent-box">
					    <text>电话:</text>
					    <input type="text" v-model="goodsInfo.phone3" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入电话" />
					</view>
					<view class="rent-box">
					    <text>关系:</text>
					    <input type="text" v-model="goodsInfo.relationship3" onInput="getEmail" style="flex:1;padding-left: 30rpx;" placeholder="请输入关系" />
					</view>
				</view>
			</view>
			
			<view class="bleck_bc" v-if="idStago">
			  <view class="bleck_bc_con" >
				<image class="bleck_bc_con_img" mode="scaleToFill" :src="$IMAGE_URL + '/go_IDPage.png'" />
				<view class="bleck_bc_con_bot"> 
				  <view class="bleck_bc_con_btnA"  @tap="onUploadIdCard">马上上传</view>
				</view>
			  </view>
			</view>

  <!-- foooter -->
      <view class="centent-box foooter">
            <view class="centent-box select" >
             <!--   <view class="selectMin" onTap="selectChecked" >
					<u-checkbox-group @change="radioChange">
						<u-checkbox 
							v-model="checkedContract" 
							shape="circle"
							:active-color="$COLOR"
						></u-checkbox>
					</u-checkbox-group>
                    <text class="selectMin_text">我已阅读并同意</text>
					<text :style="{color: $COLOR}" @tap="zulin">《租赁服务协议及相关》</text>
                </view> -->
            </view>
            <view class="btn-box foot_box u-flex u-row-between">
             <!-- <view class="btn_L">
                <view class="btn_L_text">共1件，金额</view>
                <view class="btn_L_sym">￥</view>
                <view class="btn_L_num" >￥{{((goodsInfo.zprice * goodsInfo.count)/100).toFixed(2)}}</view>
              </view> -->
              
                <button class="u-reset-button cu-btn save-btn" :class="[checkedContract ? 'subBtnY' : 'subBtnN']"
                :disabled="!checkedContract"
				:style="checkedContract?'background: linear-gradient(352deg, ' + this.$COLOR + ' 0%, '+ this.$CHANGEA+' 100%)' : ''"
                 size="default" @click="subOrder">
                 <!-- <text style="color: #8f8f8f; 	font-size: 28rpx; font-weight: bold;">立享免押租</text> -->
				 提交订单
                </button>
             
            </view>
        </view>
		
    <!-- 底部 -->
  </view>
</template>

<script>
import { mapMutations, mapActions, mapState, mapGetters } from "vuex";
import Auth from "@/shopro/permission/index.js";
export default {
 
  data() {
    return {
      platform: this.$platform.get(),
      couponList: [], //优惠券列表
      addressData: {}, //收货地址
      addressId: 0, //收货地址ID
      isDisabled: false, //提交
	  checkedContract:true,
      checkTimeId: "c1", //锚点用
      checkDayCur: 0, //默认日期
      lat: 0, //地理位置
      lng: 0,
	  startTimer:'',//起租时间
	  endTimer:'',//到期时间
	  idSta:true,//是否实名
	  lastRent:'',//剩余租金
	  firstClick:0,
	  goodsInfo:{},
	  idStago:false,
   }
  },
  computed: {
    ...mapGetters(["initStore","userInfo"]),
    // 是否可以使用优惠券
    hasCoupons() {
      if (this.couponList.length && !this.orderPre.activity_type) {
        return true;
      }
      return Boolean(
        this.couponList.length &&
          this.orderPre.activity_type &&
          this.orderPre.activity_type.indexOf("groupon") === -1 &&
          this.orderPre.activity_type.indexOf("seckill") === -1 &&
          this.orderType !== "score"
      );
    },
  },
  onShow() {
    // 监听地址
    uni.$on("SELECT_ADDRESS", (res) => {
      if (res.addressData) {
        this.addressData = JSON.parse(res.addressData);
        this.addressId = this.addressData.id;
      } else {
        this.addressId = 0;
      }
      res.addressData && uni.$off("SELECT_ADDRESS");
    });
	uni.$on("IDCARD", (res) => {
	  this.idSta = true
	});
  },
  async onLoad(query) {
	  console.log('con',JSON.parse(decodeURIComponent(query.data).replace(/%26/ig,"&").replace(/%25/ig,"%")))
	this.goodsInfo=JSON.parse(decodeURIComponent(query.data).replace(/%26/ig,"&").replace(/%25/ig,"%"))
	console.log('商品信息',this.goodsInfo)
    // this.from = this.$Route.query.from;
    // this.orderType = this.$Route.query.orderType;
    // this.grouponBuyType = this.$Route.query.grouponBuyType;
    // this.grouponId = this.$Route.query.grouponId;
    await this.init();
  },
  methods: {
    ...mapActions(["getCartList"]),

    // 初始化
    init() {
      uni.showLoading({
        title: "加载中...",
        mask: true,
      });
      return Promise.all([
		// 地址
        this.getDefaultAddress(),
		// 数据
        this.initData(),
      ]).then(() => {
		  console.log('数据初始化结束',this.goodsInfo)
        uni.hideLoading();
      });
    },
    jump(path, parmas) {
      this.$Router.push({
        path: path,
        query: parmas,
      });
    },
    // 格式化数据
    initData() {
		var data = this.goodsInfo
		let totalPrice = data.money
		let leaseTerm = data.leaseTerm ;
		if (data.trem_value ==365){
		  leaseTerm = 12
		} else if (data.trem_value == 180){
		  leaseTerm = 6 
		}else if(data.trem_value==90){
		  leaseTerm = 3
		} else if (data.trem_value==30){
		  // leaseTerm = 1
		  leaseTerm =30
		} else if (data.trem_value==14){
		  leaseTerm = 14
		} else if (data.trem_value==24){
		  leaseTerm = 24
		}
		console.log(123,totalPrice)
		// console.log("sadfasfadsfas->", data)
		// console.log(totalPrice+"--------"+leaseTerm)
		// // 首期租金
		let yu = totalPrice % leaseTerm
		let meiqiPrice = (totalPrice - yu) / leaseTerm
		data.firstRent = (yu + meiqiPrice) /  100;

		// 活动显示价格
		let activePrice = (totalPrice - 1) / (leaseTerm-1);
		console.log(activePrice)
		// 活动剩余租金
		data.activeLastRent = (activePrice / 100).toFixed(2);

		data.leaseTerm = leaseTerm

		data.dayRent = (data.money / data.trem_value / 100).toFixed(2)
		//   剩余租金
		this.lastRent = meiqiPrice / 100
		// if (leaseTerm == 30 || leaseTerm == 14 || leaseTerm == 24 ) {
		// 	  data.firstRent = data.smash /  100;
		// 	 this.lastRent = ((totalPrice) / (leaseTerm) / 100).toFixed(2)
		// }
		data.image = data.slideshows[0];
		let endAllDay = (data.trem_value - 0) * 86400;
		this.goodsInfo = data
		
		this.getTime(data.deductionInterval,data.trem_value);
		
		this.getIdCardUrl();
		this.goodsInfo.strEmail = this.userInfo.email
		console.log('用户登录信息',this.userInfo)
    },
	onUploadIdCard(){
		this.idStago = false;
		this.jump('/pages/user/authentication/index',null)
		
	},
	getIdCardUrl(){
		let sta = true;
		if(this.userInfo.idCardUrl){
		sta = true;
		}else{
		sta = false;
		}
		this.idSta = sta
	},
    // 格式日期
 //    getTime(timer){
	//  let date = new Date();

	//  let y = date.getFullYear();
	//  let m = date.getMonth() + 1;
	//  m = m < 10 ? "0" + m : m;
	//  let d = date.getDate();
	//  d = d < 10 ? "0" + d : d;
	//  let start = y + '.' + m + '.' + d;
	//  let startTim = y + '-' + m + '-' + d;
	//  // let end = (y - 0 + 1) + '.' + m + '.' + d;
	//  this.startTimer = start

	//  let t = new Date().getTime()/1000;
	//  let timNum = Math.floor(t);

	//  if(timer){
	//    let endNum = timNum + timer;
	//    let endTime = new Date(endNum*1000);
	//    let endy = endTime.getFullYear();
	//    let endm = endTime.getMonth() + 1;
	//    endm = endm < 10 ? "0" + endm : endm;
	//    let endd = endTime.getDate();
	//    endd = endd < 10 ? "0" + endd : endd;
	//    let end = endy + '.' + endm + '.' + endd;
	//    this.endTimer = end
	//  }
	// },

	getTime(deductionInterval, leaseTerm) {
	  // 校验参数
	  if (typeof deductionInterval !== 'number' || typeof leaseTerm !== 'number' || deductionInterval <= 0 || leaseTerm <= 0) {
		console.error('deductionInterval  和 leaseTerm 必须是正整数'); 
		return;
	  }
	 
	  // 获取当前时间作为开始时间
	  const startDate = new Date();
	  const startYear = startDate.getFullYear(); 
	  const startMonth = String(startDate.getMonth()  + 1).padStart(2, '0');
	  const startDay = String(startDate.getDate()).padStart(2,  '0');
	  const formattedStartDate = `${startYear}-${startMonth}-${startDay}`;
	 
	  // 计算结束时间（基于总天数）
	  const totalDays = deductionInterval * leaseTerm;
	  const endDate = new Date(startDate.getTime()  + totalDays * 24 * 60 * 60 * 1000); // 毫秒计算 
	 
	  const endYear = endDate.getFullYear(); 
	  const endMonth = String(endDate.getMonth()  + 1).padStart(2, '0');
	  const endDay = String(endDate.getDate()).padStart(2,  '0');
	  const formattedEndDate = `${endYear}-${endMonth}-${endDay}`;
	 
	  console.log(' 开始时间:', formattedStartDate);
	  console.log(' 结束时间:', formattedEndDate);
	 
	  this.startTimer = formattedStartDate,
	  this.endTimer = formattedEndDate
	},

   
	radioChange(e){
		console.log(e.length)
		
	},
    // 获取位置
    async getLocation() {
      let authState = await new Auth("userLocation").check();
      // #ifdef MP ||　APP-VUE
      authState &&
        uni.getLocation({
          type: "gcj02",
          success: (res) => {
            this.lng = res.longitude;
            this.lat = res.latitude;
            this.getStoreAddress();
          },
          fail: (err) => {
            console.log("确认订单自提位置：", err);
          },
        });
      // #endif
      // #ifdef H5
      uni.getLocation({
        type: "gcj02",
        success: (res) => {
          this.lng = res.longitude;
          this.lat = res.latitude;
          this.getStoreAddress();
        },
      });
      // #endif
    },
    // 提交订单
    subOrder() {
		this.isDisabled = true;
		let promoteId = uni.getStorageSync('promoteId');
		let promoteUserId = uni.getStorageSync('promoteUserId');
		let shopProductSid = uni.getStorageSync('shopProductSid');
	  // this.checkedContract = false
     	let reg = /^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$/
		const regPhone = /^1((34[0-8])|(8\d{2})|(([35][0-35-9]|4[579]|66|7[35678]|9[1389])\d{1}))\d{7}$/
		if (!reg.test(this.goodsInfo.strEmail)){
			this.$u.toast("请填写正确的邮箱地址");
			return;
		}
		console.log(this.$EMERGENCY_CONTACT)
		if(this.$EMERGENCY_CONTACT){
			if(!this.goodsInfo.name1){
				this.$u.toast('请输入第一个联系人姓名');
				return;
			}

			if(!this.goodsInfo.phone1){
				this.$u.toast('请输入第一个联系人电话');
				return;
			}

			if(!regPhone.test(this.goodsInfo.phone1)){
				this.$u.toast('请输入正确的手机号');
				return;
			}
			
			if(!this.goodsInfo.relationship1){
				this.$u.toast('请输入第一个联系人关系');
				return;
			} 

			if(!this.goodsInfo.name2 ){
				this.$u.toast('请输入第二个联系人姓名');
				return;
			}

			if(!this.goodsInfo.phone2 ){
				this.$u.toast('请输入第二个联系人电话');
				return;
			}
			
			if(!regPhone.test(this.goodsInfo.phone2)){
				this.$u.toast('请输入正确的手机号');
				return;
			}

			if(!this.goodsInfo.relationship2){
				this.$u.toast('请输入第二个联系人关系');
				return;
			} 

			if(!this.goodsInfo.name3){
				this.$u.toast('请输入第三个联系人姓名');
				return;
			}

			if(!this.goodsInfo.phone3){
				this.$u.toast('请输入第三个联系人电话');
				return;
			}
			
			if(!regPhone.test(this.goodsInfo.phone3)){
				this.$u.toast('请输入正确的手机号');
				return;
			}

			if(!this.goodsInfo.relationship3){
				this.$u.toast('请输入第三个联系人关系');
				return;
			}
		}
			//地址为空弹出地址
		if (!this.addressData.consignee) {
			this.jump('/pages/user/address/list', { from: 'order' })
			 return;
		}
		
		//没有实名
		if(!this.idSta) {
			this.idStago=true
			 return;
		}
		let num = this.firstClick;
		if(!this.idSta && this.firstClick == 0){
			num += 1;
			this.firstClick = num
			uni.hideLoading();
			return;
		}
		let setMeal = 0;
		if(this.goodsInfo.staShow == "租完归还"){
			setMeal = 1
		}
		 console.log(this.goodsInfo)
		 // 订单数据详细数据
		 const data = Object.assign(
			 {},
			 {
			   // 商品基础数据
			   title: this.goodsInfo.msg,// 商品名
			   // 商品基础数据
			   title: this.goodsInfo.msg,//商品名字
			   id: this.goodsInfo.id,//商品id
			   skuId: this.goodsInfo.skuId,//商品skuId
			   version: this.goodsInfo.version,//版本
			   type:this.goodsInfo.type,// 成色 0为新，1为二手
			   // clipCoupons: this.data.clipCoupons ? this.data.clipCoupons : 0,
			   model: {
				   price: this.goodsInfo.price,//金额
				   leaseTerm: this.goodsInfo.trem_value,//期数
			   },
			   cycle: this.goodsInfo.cycle,//周期
			   termUnit:this.goodsInfo.termUnit,//期数单位 1:月2:周3:日
			   sellPrice: this.goodsInfo.sellPrice,//售卖金额
			   pastType:this.goodsInfo.pastType,//二手标签几几新
			   staShow:this.goodsInfo.staShow,//套餐"租完归还"或租完归还
			   neicun:this.goodsInfo.neicun,//内存
			   // productType:this.data.productType,
			   price:this.goodsInfo.price,//金额
			   // oneprice:this.data.newfirstRent * 100,
			   color:this.goodsInfo.color,//颜色
			   deposit: this.goodsInfo.cash,//押金
			   buyOutPrice: this.goodsInfo.buyOut,//买断价
			   purchasePrice: this.goodsInfo.purchase,//采购价
			   // mylProductId: this.data.mylProductId,
			   setMeal: setMeal,//0租完即送1租完归还
			   image: this.goodsInfo.slideshows,//商品图片
			   detail: this.goodsInfo.detail,//商品详情
			   smash: this.goodsInfo.smash,//碎屏保障
			   saleQuantity: this.goodsInfo.saleQuantity,//数量
			   shoppingType:this.goodsInfo.shoppingType,//商品类型暂时弃用1租赁2先享后付
			 }
		 );
		 let contact = '';
		 if('' != this.goodsInfo.name1){
		   contact = `紧急联系人1：姓名：${this.goodsInfo.name1}, 电话:${this.goodsInfo.phone1}, 关系:${this.goodsInfo.relationship1} and 紧急联系人2：姓名：${this.goodsInfo.name2}, 电话:${this.goodsInfo.phone2}, 关系:${this.goodsInfo.relationship2} and 紧急联系人3：姓名：${this.goodsInfo.name3}, 电话:${this.goodsInfo.phone3}, 关系:${this.goodsInfo.relationship3}`; 
		 }
		 let  params = {
			 isAgreement: 0,
			 agreementNo: null,
 
			 testOrder: this.goodsInfo.testOrder,
 
			 params: JSON.stringify(data),
 
			 tit: this.addressData.consignee,
			 province: this.addressData.province,
			 city: this.addressData.city,
			 district: this.addressData.area,
			 street: "",//街道
			 address: this.addressData.address,
			 phone: this.addressData.phone,
			 aliChecked:this.goodsInfo.aliChecked,
			 invoice: this.goodsInfo.invoice,
			 cont: this.goodsInfo.cont ? this.goodsInfo.cont : '',//备注
			 channelType:'',//渠道
			 orderAuthCode:'',	//小程序订单中心授权码
			 latitude:"",
			 longitude:"",
			 orderAuthCode:this.goodsInfo.formId,
			 currentAddress:this.addressData.province + '-'+ this.addressData.city + '-'+ this.addressData.area,
			 // channelType: this.goodsInfo.beFromNum,
			 email: this.goodsInfo.strEmail,
			 contact : contact,
		 }
			 let that = this;
			 
			if(shopProductSid){
				params.shopProductSid = shopProductSid;
			}
			console.log('推广商id',promoteId)
			console.log('推广员id',promoteUserId)
			console.log('商家id',shopProductSid)

			if(promoteId){
				params.promoteId = promoteId;
			}
			if(promoteUserId){
				params.promoteUserId = promoteUserId;
			}
			
			if(that.goodsInfo.clickId){
				params.clickId = that.goodsInfo.clickId;
			}
			
			console.log('下单参数params',data)
			console.log('下单参数',params)
			// return ;
			 that.$http("goods.saveOrder", params, '加载中...').then((res) => {
				 console.log(res.data)
			 	if(res.code!=200) {
					that.$u.toast(res.msg);
					my.alert({
						content:json.msg
					});
					return
				}
				console.log(123,this.goodsInfo.aliChecked)
				if(this.goodsInfo.aliChecked == 1){
					that.$http("goods.alipay", {id:res.data.orid,oid:res.data.oid}).then((pay) => {
						console.log('支付宝支付',pay)
						window.location.href = pay.data;
						// uni.requestPayment({
						// 	provider: 'alipay',
						// 	orderInfo: pay.data, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
						// 	success: function (res) {
						// 		that.$u.toast('支付成功！');
						// 		that.isPay = false;
						// 		uni.switchTab({
						// 			url: '/pages/index/user'
						// 		});
						// 	},
						// 	fail: function (err) {
						// 		that.isPay = false;
						// 		that.$u.toast('支付失败！');
						// 		console.log('fail:' + JSON.stringify(err));
						// 	}
						// });
									
					})
				}else{
					that.jump('/pages/order/list', { type: '-2' })
					// uni.switchTab({
					// 	url: '/pages/index/user'
					// });
				}
				// uni.showModal({
				//   title: '提示',
				//   content: '平台不会以任何形式收取押金',
				//   showCancel: false,
				//   success (res) {
				// 	if (res.confirm) {
				// 		uni.switchTab({
				// 			url: '/pages/index/user'
				// 		});
				// 	}
				//   }
				// })
			
				// that.jump('/pages/order/list', { type: '-2' })
				// that.jump('/pages/user/verifyIdentity/index',{oid:res.data})
				// this.$http("goods.freeze", {id:res.data}).then((pay) => {
				// 	console.log('支付',pay)
				// 	uni.requestPayment({
				// 		provider: 'alipay',
				// 		orderInfo: pay.data, //微信、支付宝订单数据 【注意微信的订单信息，键值应该全部是小写，不能采用驼峰命名】
				// 		success: function (res) {
				// 			that.$u.toast('支付成功！');
				// 			that.jump('/pages/user/verifyIdentity/index')
				// 			console.log('success:' + JSON.stringify(res));
				// 		},
				// 		fail: function (err) {
				// 			that.jump('/pages/order/list', { type: '-2' })
				// 			console.log('fail:' + JSON.stringify(err));
				// 		}
				// 	});
								
				// })
				
			 });
			 this.checkedContract = true
    },
		confirm(value) {
			// 输入框的值
			console.log(value)
			// TODO 做一些其他的事情，手动执行 close 才会关闭对话框
			// ...
			this.$refs.popup.close()
		},
    // 初始地址
    getDefaultAddress() {
		this.$http("address.defaults", {
			isDefault:1
		}).then((res) => {
			if (res.code === 200 && res.data) {
			  this.addressData = res.data;
			  this.addressId = res.data.id;
			}
		});
    },
	zulin(){
		let data = new Date()
		data = data.getFullYear() + '年' + (data.getMonth()+1) + '月' + data.getDate()+'日'
		let item = {
			createtime:data,  // 时间
			leaseTerm:Math.floor(this.goodsInfo.trem_value/30),// 租期
			allRent:this.goodsInfo.buyOut*this.goodsInfo.count/100 , // 总租金
			tit:this.addressData.consignee , //
			phone:this.addressData.phone,
			shopsVo: this.goodsInfo.shops,
			userVo: this.userInfo,
			province: this.goodsInfo.province,
			city: this.addressData.city,
			district: this.addressData.district,
			address: this.addressData.address,
			testOrder: this.goodsInfo.testOrder,
			params:{
				// 商品基础数据
				title: this.goodsInfo.msg,
				id: this.goodsInfo.id,
				skuId: this.goodsInfo.skuId,
				version: this.goodsInfo.version,
				clipCoupons: this.goodsInfo.clipCoupons ? this.goodsInfo.clipCoupons : 0, //是否有优惠券
				model: {
				    price: this.goodsInfo.money * this.goodsInfo.count,
				    leaseTerm: this.goodsInfo.trem_value * 4,
				},
				deposit: this.goodsInfo.cash,
				buyOutPrice: this.goodsInfo.buyOut,
				purchasePrice: this.goodsInfo.purchase,
				     
				image: this.goodsInfo.image,
				detail: this.goodsInfo.detail,
				smash: this.goodsInfo.smash
			}
		}

		uni.navigateTo({
			url: `/pages/user/agreementList/agreementList?param=${encodeURIComponent(JSON.stringify(item))}`
		})
	},
    // 可用优惠券
    getCoupons() {
      let that = this;
      // that
      //   .$http("order.coupons", {
      //     goods_list: that.goodsInfo,
      //     from: that.from,
      //     address_id: that.addressId,
      //     coupons_id: that.couponId,
      //     order_type: that.orderType,
      //   })
      //   .then((res) => {
		  var res = {"code":1,"msg":"获取成功","time":"1688437330","data":[]}
          if (res.code === 1) {
            that.couponList = res.data;
          }
        // });
    },

    // 选择优惠券
    selectCoupon(index) {
      this.couponId = index >= 0 ? this.couponList[index].user_coupons_id : 0;
    },

    // 是否同意协议
    checkProtocol() {
      this.isProtocol = !this.isProtocol;
    },
  
  },
};
</script>

<style lang="scss" scoped>
// 收货地址栏
.head_box {
  background-color: #fff;
}

.add-address-box {
  min-height: 100rpx;
  background: url($IMG_URL + "/imgs/order/order_address_line.png") no-repeat;
  background-size: 100% auto;
  background-position: bottom center;

  .select-notice {
    font-weight: 400;
    color: rgba(153, 153, 153, 1);
    line-height: 40rpx;
  }

  .name,
  .phone {
    font-size: 30rpx;
    font-weight: 500;
  }

  .phone {
    margin: 0 20rpx;
  }

  .tag {
    background: rgba(233, 191, 113, 0.2);
    border-radius: 6rpx;
    padding: 0 16rpx;
    line-height: 38rpx;
    color: #a8700d;
    font-size: 22rpx;
  }

  .detail {
    .address {
      margin-top: 25rpx;
      width: 543rpx;
      font-size: 26rpx;

      font-weight: 400;
      color: rgba(153, 153, 153, 1);
      line-height: 40rpx;
    }
  }
}
.centent-box {
    /* width: 702rpx; */
    margin: 0 auto;
    background-color: #fff;
    border-radius: 8rpx;
    margin-bottom: 24rpx;
}
.centent-box:last-child{
    margin-bottom: 0rpx;
}

.detail {
  padding: 28rpx 0 0;
  box-sizing: border-box;
}
.detail_goods{
  width: 659rpx;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
}
.detail-img {
    width: 156rpx;
    height: 156rpx;
}
.detail-info {
    width: 474rpx;
    height: 180rpx;
    box-sizing: border-box;
}

.detail-info-title {
    font-size: 28rpx;
    font-weight: 400;
    color: #121212;
    line-height: 40rpx;
}
.detail-info-text{
  font-size: 22rpx;
  color: #999999;
  line-height: 40rpx;
}
.detail-info-combo {
    display: inline-block;
    padding: 5rpx;
    font-size: 22rpx;
    border-radius: 10rpx;
    background-color: #E9E7E8;
    color: #666;
}
.detail-info-trem {
    display: flex;
    justify-content: space-between;
}
.detail-info-line{
  margin-top: 4rpx;
}

.detail_time{
  width: 654rpx;
  height: 94rpx;
  margin: 24rpx auto 0;
  background-color: rgba(22, 119, 255, 0.07);
  border-radius: 48rpx;
  display: flex;
  /* justify-content: space-between; */
  align-items: center;
  box-sizing: border-box;
  padding-left: 44rpx;
}
.detail_time_min{
  width: 230rpx;
  display: flex;
  align-items: center;
}
.detail_time_minT{
  margin-left: 100rpx;
}
.detail_time_min_L{
  width: 62rpx;
  height: 62rpx;
}
.detail_time_min_R{
  margin-left: 10rpx;
}
.detail_time_min_R_tit{
  font-size: 28rpx;
  font-weight: bold;
  color: #333333;
  line-height: 40rpx;
}
.detail_time_min_R_text{
  font-size: 24rpx;
  color: rgba(51, 51, 51, 0.3);
  line-height: 34rpx;
}





.detail_hint{
  width: 100%;
  height: 66rpx;
  background: linear-gradient(90deg, #FFEACF 0%, #FFFCF7 100%);
  margin-top: 24rpx;
  display: flex;
  justify-content: center;
  align-items: center;
}
.detail_hint_img{
  width: 28rpx;
  height: 28rpx;
}
.detail_hint_text{
  font-size: 24rpx;
  color: #E89765;
  margin-left: 8rpx;
}


/* rent */
.rent {
    padding-bottom: 24rpx;
}
.rent-box {
  width: 654rpx;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 26rpx;
  color: #999999;
  line-height: 42rpx;
  margin-top: 24rpx;
}
.rent-frist {
  height: 92rpx;
  border-bottom:1rpx dashed #eee;
  margin-top: 0;
}
.rent-frist-tit{
  font-size: 28rpx;
  font-weight: bold;
  color: #333333;
  /* line-height: 44rpx; */
}
.rent-frist-num{
  font-size: 40rpx;
  font-weight: bold;
  color: #333333;
  /* line-height: 56rpx; */
  letter-spacing: -2rpx;
}
// 身份证
.identity{
  display: flex;
  justify-content: space-between;
  position: relative;
  background-color: rgba(0, 0, 0, 0);
}
.identity_L{
  width: 376rpx;
  padding: 24rpx;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}
.identity_L_tit{
  font-size: 32rpx;
  font-weight: bold;
  color: #4d5255;
  line-height: 44rpx;
}
.identity_L_text{
  font-size: 24rpx;
  color:  #535544;
  line-height: 34rpx;
  margin-top: 8rpx;
}
.identity_R{
  width: 327rpx;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  box-sizing: border-box;
  padding-right: 24rpx;
  position: relative;
  z-index: 1;
}
.identity_R_btn{
  width: 148rpx;
  height: 56rpx;
  background: #FFFFFF;
  border-radius: 28rpx;
  border: 2rpx solid rgba(22, 119, 255, 0.2);
  font-size: 28rpx;
  font-weight: bold;
  color: #1677FF;
  line-height: 56rpx;
  text-align: center;
  letter-spacing: 1rpx;
}
.identity_bc{
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}
/* remark */
.remark {
    padding: 30rpx;
    box-sizing: border-box;
    color: #999;
    display: flex;
    align-items: center;
    font-size: 26rpx;
    line-height: 42rpx;
}

.remark input {
    height: 30rpx;
	font-size: 26rpx;
}

.foot-box-wrap {
  height: calc(100rpx + env(safe-area-inset-bottom) / 2);
  padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  position: relative;
  width: 100%;
  z-index: 70;
}

.foot-box {
  position: fixed;
  display: flex;
  align-items: center;
  width: 100%;
  height: calc(100rpx + env(safe-area-inset-bottom) / 2);
  border-top: 1rpx solid #eeeeee;
  background-color: #fff;
  z-index: 998;
  bottom: 0;
  padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  padding: 0 30rpx;
  .btn-hover {
    color: #fff;
  }

  .num {
    font-size: 26rpx;
    color: #999;
  }

  .all-money {
    margin: 0 60rpx 0 20rpx;

    .price {
      color: #ff0000;
    }
  }

  .sub-btn {
    width: 210rpx;
    line-height: 70rpx;
    background: linear-gradient(
      90deg,
      rgba(233, 180, 97, 1),
      rgba(238, 204, 137, 1)
    );
    box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
    border-radius: 50rpx;
    font-size: 28rpx;
    color: #fff;
  }
}




/* foooter */
.foooter {
  width: 100vw;
  height: 200rpx;
  background-color: #fff;
  position: fixed;
  left: 0;
  bottom: 0;
  padding: 16rpx 24rpx 0;
  box-sizing: border-box;
}


.btn_wrap{
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.btn_L{
  display: flex;
  align-items: flex-end;
  flex: 1;
  white-space: nowrap;
}
.btn_L_text{
  font-size: 24rpx;
  color: #333333;
  line-height: 40rpx;
}
.btn_L_sym{
  font-size: 28rpx;
  color: #E62E20;
  position: relative;
  right: -6rpx;
  top: 0rpx;
}
.btn_L_num{
  font-size: 40rpx;
  color: #E62E20;
  letter-spacing: -2rpx;
  font-weight: bold;
  position: relative;
  top: 4rpx;
}
.btn-box {
		height: 100rpx;

		.cu-btn {
			width: 340rpx;
			line-height: 70rpx;
			border-radius: 35rpx;
			font-size: 28rpx;

			font-weight: 500;
			color: rgba(255, 255, 255, 0.9);
			padding: 0;
		}

		.cart-btn {
			background: linear-gradient(90deg, rgba(103, 104, 105, 1), rgba(82, 82, 82, 1));
			box-shadow: 0px 2rpx 5rpx 0px rgba(102, 103, 104, 0.46);
		}

		.buy-btn {
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
		}

		.save-btn {
			width: 710rpx;
			height: 70rpx;
			background: linear-gradient(90deg, rgba(233, 180, 97, 1), rgba(238, 204, 137, 1));
			font-size: 28rpx;
			font-weight: 500;
			color: rgba(255, 255, 255, 1);
			border-radius: 35rpx;
			padding: 0;
		}

		.cancel-btn {
			width: 710rpx;
			height: 70rpx;
			background: rgba(221, 221, 221, 1);
			font-size: 28rpx;
			font-weight: 500;
			color: #999999;
			border-radius: 35rpx;
			padding: 0;
		}
	}
	

.bottom-backgroind {
      position: absolute;
      height: 8rpx;
      width: 100%;
      bottom: 0;
      left: 0px;
    }
.subBtnY{
	background: linear-gradient(352deg, #ffcb31 0%, #ffcb31 100%);
	width: 210rpx;
	line-height: 70rpx;
	background: linear-gradient(
	90deg,
	rgba(233, 180, 97, 1),
	rgba(238, 204, 137, 1)
	);
	// 按钮阴影
	// box-shadow: 0px 7rpx 6rpx 0px rgba(229, 138, 0, 0.22);
	border-radius: 50rpx;
	color: #ffffff;
}
.subBtnN{
	background: linear-gradient(352deg, #BBBBBB 0%, #CCCCCC 100%);
	width: 210rpx;
	line-height: 70rpx;
	border-radius: 50rpx;

}
.subBtn_img{
  width: 24rpx;
  height: 40rpx;
  margin-right: 12rpx;
  margin-top: 4rpx;
}



.identity{
  display: flex;
  justify-content: space-between;
  position: relative;
  background-color: rgba(0, 0, 0, 0);
}
.identity_L{
  width: 376rpx;
  padding: 24rpx;
  box-sizing: border-box;
  position: relative;
  z-index: 1;
}
.identity_L_tit{
  font-size: 32rpx;
  font-weight: bold;
  color: #FFFFFF;
  line-height: 44rpx;
}
.identity_L_text{
  font-size: 24rpx;
  color: rgba(255, 255, 255, 0.6);
  line-height: 34rpx;
  margin-top: 8rpx;
}
.identity_R{
  width: 327rpx;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  box-sizing: border-box;
  padding-right: 24rpx;
  position: relative;
  z-index: 1;
}
.identity_R_btn{
  width: 148rpx;
  height: 56rpx;
  background: #FFFFFF;
  border-radius: 28rpx;
  border: 2rpx solid rgba(22, 119, 255, 0.2);
  font-size: 28rpx;
  font-weight: bold;
  color: #1677FF;
  line-height: 56rpx;
  text-align: center;
  letter-spacing: 1rpx;
}
.identity_bc{
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

/* 遮罩 */
.bleck_bc{
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  box-sizing: border-box;
  padding-top: 16vh;
}
.bleck_bc_con{
  width: 630rpx;
  height: 806rpx;
  position: relative;
  animation: idGoPop 0.3s;
}
@keyframes idGoPop{
  0%{
    transform: scale(0.8);
  }
  100%{
    transform: scale(1);
  }
}
.bleck_bc_con_img{
  width: 630rpx;
  height: 806rpx;
  position: absolute;
  left: 0;
  top: 0;
}
.bleck_bc_con_bot{
  width: 100%;
  height: 184rpx;
  padding-top: 50rpx;
  position: absolute;
  left: 0;
  bottom: 0;
}
.bleck_bc_con_btnA{
  width: 466rpx;
  height: 80rpx;
  background: #FFFFFF;
  border-radius: 40rpx;
  text-align: center;
  line-height: 80rpx;
  font-size: 32rpx;
  font-weight: bold;
  color: #1677FF;
  letter-spacing: 2rpx;
  margin: 0 auto;
}
.bleck_bc_con_btnB{
  width: 160rpx;
  font-size: 28rpx;
  color: rgba(255, 255, 255, 0.5);
  line-height: 40rpx;
  text-align: center;
  margin: 26rpx auto 0;
}

</style>
